#include <common.h>

class Solution {
public:
    bool canJump(vector<int> &nums) {
        int range=1;
        for(int i=0;i<nums.size();i++) {
            if(range>=nums.size())return true;
            //可达
            if(range>=i+1) {
                range=max(range,nums[i]+i+1);
            }else {
                break;
            }
        }
        return false;
    }
};

int main() {
    auto sp = new Solution();
    vector<int> v = {3,2,1,0,4};
    bool can_jump = sp->canJump(v);
    cout << can_jump << endl;
    return 0;
}
